export type ApiRelationship = {
  id: number
  status: 'pending' | 'active' | 'revoked'
  invite_code: string
  initiator_id: number
  partner_id: number | null
  confirmed_at: string | null
  created_at?: string | null
  updated_at?: string | null
}

export type ApiUser = {
  id: number
  email: string
  username: string
  nickname?: string | null
  is_active: boolean
  verified_at: string | null
  prefs: Record<string, unknown> | null
  active_relationship_id: number | null
  partner_display_name?: string | null
  relationship_started_at?: string | null
  partner_profile: {
    partner_name: string | null
    relationship_start_date: string | null
    timezone: string | null
    notification_prefs: Record<string, unknown> | null
  } | null
}

export type ApiDiaryEntry = {
  id: number
  title: string
  content_md: string
  mood: string | null
  tags: string[]
  visibility: string
  ai_summary: string | null
  relationship_id: number | null
  created_at: string | null
}

export type ApiDiaryComment = {
  id: number
  user_id: number
  diary_entry_id: number
  content: string
  mood: string | null
  created_at?: string | null
  author_name?: string | null
}

export type ApiAnniversary = {
  id: number
  name: string
  date: string
  recurrence: string
  reminder_offset_days: number
  relationship_id: number | null
  created_at?: string | null
  is_lunar?: boolean
  lunar_date_str?: string | null
  countdown_mode?: 'down' | 'up' | 'both'
}

export type ApiCycleLog = {
  id: number
  start_date: string
  end_date: string | null
  symptoms: Record<string, unknown> | null
  notes: string | null
  relationship_id: number | null
  created_at?: string | null
}

export type ApiCyclePrediction = {
  id: number
  phase: string
  phase_label?: string | null
  start_date: string
  end_date: string
  confidence: number
  relationship_id: number | null
}

export type ApiCycleDayLog = {
  id?: number
  date: string
  flow_level: string
  symptoms: Record<string, unknown> | null
  mood: string | null
  temperature: number | null
  relationship_id?: number | null
}

export type ApiTokenResponse = {
  access_token: string
  refresh_token: string
  token_type: string
  expires_in: number
  refresh_expires_in: number
}

export type ApiAISuggestion = {
  message: string
  tags: string[]
  prompt_id: string | null
}

export type ApiChatMessage = {
  role: 'assistant' | 'user'
  content: string
}

export type ApiChatHistory = {
  thread_id: string | null
  messages: ApiChatMessage[]
  has_more: boolean
  summary: string | null
  next_offset: number | null
  total: number
}

export type ApiDecisionPreset = {
  id: number
  title: string
  options: string[]
  style: string
  is_shared: boolean
  color_seed: string | null
  usage_count: number
  last_used_at: string | null
  last_result: string | null
  created_at: string
  updated_at: string
}

export type ApiDecisionSpinResult = {
  title: string
  options: string[]
  selected_index: number
  selected_value: string
  preset_id: number | null
}
